import { useState } from "react";
import { useRootStore } from "../store/index"
function Header() {
    const [title, setTitle] = useState("");
    const { todoStore } = useRootStore();
    const { addTodo } = todoStore;
    return (
        <div>
            <input value={title}
                onChange={e => setTitle(e.target.value)}
                onKeyUp={e => {
                    if (e.key !== 'Enter') return
                    addTodo(title)
                    setTitle("")
                }}
            />
        </div>
    )
}

export default Header